package com.houor.device.controller.data;

import org.houor.utility.NumberUtility;

/**
 * 传感器数据
 * 
 * @author Houor
 *
 * @createTime 2017-04-23 22:57
 */
public class SensorReportData extends ReportData {

	/**
	 * 传感器类型
	 */
	private byte sensorType;

	/**
	 * 通道
	 */
	private byte deviceChannel;

	/**
	 * 传感器采集值
	 */
	private int value;

	public void init(byte[] content, int xiugai) {
		this.sensorType = content[0];
		this.deviceChannel = content[1];
		this.value = NumberUtility.byteArray2Int(new byte[] { content[2], content[3], content[4], content[5] });
	}

	@Override
	public void init(byte[] content) {
		this.sensorType = content[0];
		this.value = NumberUtility.byteArray2Int(new byte[] { (byte) 0, (byte) 0, content[1], content[2] });
	}

	public byte[] getBytes(int xiugai) {
		byte[] content = new byte[6];
		content[0] = this.sensorType;
		content[1] = this.deviceChannel;
		System.arraycopy(NumberUtility.int2ByteArray(this.value), 0, content, 2, 4);
		return content;
	}

	@Override
	public byte[] getBytes() {
		byte[] content = new byte[3];
		content[0] = this.sensorType;
		// content[1] = this.deviceChannel;
		System.arraycopy(NumberUtility.int2ByteArray(this.value), 2, content, 1, 2);
		return content;
	}

	public byte getSensorType() {
		return sensorType;
	}

	public void setSensorType(byte sensorType) {
		this.sensorType = sensorType;
	}

	public byte getDeviceChannel() {
		return deviceChannel;
	}

	public void setDeviceChannel(byte deviceChannel) {
		this.deviceChannel = deviceChannel;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

}
